// --= send an ajax request to update the movies vote for the current user =--
function process_rating(movie_id, vote)
{


	ajax_http_request('index.php?what=movie&do=ajax_vote&movie='+ movie_id +'&vote='+ vote, 'update_vote_results');

	// --= now we have init the ajax call, lets update our voting graphics to reflect the vote registered =--
	update_rating_img(vote);

}

function update_vote_results(data)
{

	tmp = data.split('|');

	rating	= tmp[0];
	votes	= tmp[1];
	min		= tmp[2];

	document.getElementById('rating_votes').innerHTML = votes + ' ' + (votes == 1 ? 'Vote' : 'Votes');

	if(votes >= min)
	{
		document.getElementById('rating').innerHTML = rating;
	}
	else
	{
		document.getElementById('rating').innerHTML = min +' votes required';
	}
}

// --= Updates the voting graphics =--
function update_rating_img(vote)
{
	var obj = document.getElementById('rating_box');

	var imgs = obj.getElementsByTagName('IMG');

	for(var i = 0; i < imgs.length; i++)
	{

		var img_obj = imgs[i];

		base = img_obj.src.substring(0, img_obj.src.lastIndexOf('/') + 1);

		if(i < vote)
		{
			// --= rating_100 =--
			img_obj.src = base + 'rating_100.png';
		}
		else
		{
			// --= rating_0 =--
			img_obj.src = base + 'rating_0.png';
		}

	}

}